package com.google.code.virtualhockey.vhx.shared.rpc.helper;

import com.google.code.virtualhockey.vhx.shared.rpc.IResponse;

import java.io.Serializable;

/**
 * <p>
 * General purpose response implementation. This general response class could be
 * used if a single value is expected to be sent back to the command issuer.
 * </p>
 *
 * <p>
 * This class is abstract to force users to create more specific sub-classes for
 * the responses they wish to send. Keeping the type parameter open to every
 * possible Serializable class slows down the GWT compiler as a serialisation
 * policy will be created for every possibly serializable concrete sub-type
 * (remember that type parameters are erased at runtime).
 * </p>
 */
public abstract class SimpleResponse<T extends Serializable> implements IResponse
{
  private T m_value;

  /**
   * Private argument-less constructor for GWT/RPC.
   */
  protected SimpleResponse()
  {
  }

  /**
   * Creates a new SimpleResponse that wraps the given value.
   *
   * @param value the value to be set for this answer
   */
  public SimpleResponse( T value )
  {
    m_value = value;
  }

  /**
   * Returns the encapsulated response value.
   */
  public T get()
  {
    return m_value;
  }
}
